﻿using Dapper;
using Datory;
using SSCMS.Models;
using SSCMS.Models.AddModels;
using SSCMS.Repositories.AddRepositories;
using SSCMS.Services;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSCMS.Core.Repositories.AddRepositories
{
    public class HuiyuanRepository:IHuiyuanRepository
    {
        private IDbConnection _dbConnection;
        private readonly ISettingsManager _settingsManager;
        private Repository<huiyuan> _repository;
        public HuiyuanRepository(ISettingsManager settingsManager)
        {
            _dbConnection = settingsManager.LocalPgDatabase.GetConnection();
            _settingsManager = settingsManager;
            _repository = new Repository<huiyuan>(settingsManager.LocalPgDatabase, settingsManager.Redis);
        }

        public IDatabase Database => _repository.Database;

        public string TableName => _repository.TableName;

        public List<TableColumn> TableColumns => _repository.TableColumns;

        public async Task<huiyuan> GetHuiyuan()
        {
            return await _dbConnection.QueryFirstOrDefaultAsync<huiyuan>("select * from huiyuan where id = 2136770");
            
        }
    }
}
